package com.dzh.dzhhub.service.impl;

import com.dzh.dzhhub.dao.PermissionDao;
import com.dzh.dzhhub.entity.Permission;
import com.dzh.dzhhub.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author DZHooo
 * @version 1.0
 * @date 2021/11/16 10:46
 * @description: TODO
 */

@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionDao permissionDao;

    @Override
    public Permission getUserPermission(String username) {
        Permission userPermission = permissionDao.getUserPermission(username);
        String adminRoleId = "1";
        if(adminRoleId.equals(userPermission.getRoleId())) {
            Set<String> menuList = permissionDao.getAllMenu();
            Set<String> permissionList = permissionDao.getAllPermission();
            userPermission.setMenuList(menuList);
            userPermission.setPermissionList(permissionList);
        }
        return userPermission;
    }


}
